<div class="tab-pane tab-pane-global fade active show" id="id0">
    {% if error %}
      <p>{{ error }}</p>
    {% else %}

<table id="table--highmem" class="table" data-log-id="{{ log_id }}" >

</table>
<script>
var log_id = "{{ log_id }}"
var scantypeMap={
"1": "Normal",
"2": "High Memory Detection",
"3": "Polling Issues",
"4": "AI Scan",
}


var table = new Tabulator("#table--highmem", {
       layout:"fitColumns",
       height:"100%",
       cellVertAlign:"middle", 
       columns:[
               {
                formatter:"rownum", 
                hozAlign:"center", 
                width:10,
               },
               {
                title:"Name", 
                field:"name", 
                width:150,
                formatter: function(cell, formatterParams, onRendered){
		             return "<a class=\"text-info\" style=\"text-decoration: underline;\">" + cell.getValue() + "</a>"
                           },
                cellClick:function(e, cell){ 
                            scantype=cell.getRow().getData()['scantype']  
                            if (scantype=="2"){
                              createTab('id0', 'High memory detection', '/fetch_memory/'+log_id, false);
                            } else {
                              id=cell.getRow().getData()['id'] ;
                              url="/fetch_description/"+log_id+"/"+id;
                              console.log(url);
                              tabId="tab--des-"+id;
                              header="&nbsp;<span class=\"text-info tab-icon\"><i class=\"fas fa-file fa-1x\" aria-hidden=\"true\"></i></span>"+"Detail Info";
                              createTab(tabId, header, url)
                            }
                          },
               },
               {
                title:"Healthy Level", 
                field:"healthy_level", 
                width:140,
                formatter:"lookup",
	        formatterParams:{
	          "0": "<img src=\"/static/img/icons_knownissues/ok.ico\" class=\"table-cell-ico\" ></img>&nbsp;</img><span>OK</span>",
	          "1": "<img src=\"/static/img/icons_knownissues/warning.ico\" class=\"table-cell-ico\" >&nbsp;</img><span>Warning</span>",
	          "2": "<img src=\"/static/img/icons_knownissues/error.ico\" class=\"table-cell-ico\" >&nbsp;</img><span>Error</span>",
	          "3": "<img src=\"/static/img/icons_knownissues/missing.ico\" class=\"table-cell-ico\" >&nbsp;</img><span>Missing File</span>",
	          "4": "<img src=\"/static/img/icons_knownissues/missing.ico\" class=\"table-cell-ico\" >&nbsp;</img><span>Undefined</span>",
	        },},
	       {
                title:"Brief Review", 
                field:"short_description", 
                formatter:function(cell, formatterParams, onRendered){ 
                             vals = cell.getValue().split("\n"); 
                             lines = "<ul>"+vals.map(function (l) {
                                      if (l.split(" ") != [] && l !="") {
                                         return '<li>' + l + '</li>';
                                      } else {
                                         // Remove blank line
                                         return '';
                                      }
                                     }).join('')+"</ul>"
                             return lines
	                    },
               },
       ],
});

$.get("/fetch_knownissue_json/{{ log_id }}", function(data, status){
	if (data["error"] == 0){
            tableData = data["data"];
            table.setData(tableData)
	}
})


</script>

    {% endif %}
</div>


